﻿@page "/invreportclasstable"
@inject INavInvReportClassService NavInvReportClassService

<PageTitle>Inventory Report Table (Class)</PageTitle>
@* <div style="position: sticky; top: 3.5rem; z-index: 1; background-color: White">
    <div class="row position-relative">
        <div class="col mt-2">
            @if (NavInvReportClassDtos.Count != 0)
            {
                <span>总行数:@NavInvReportClassDtos.Count</span>
            }
        </div>
    </div>
</div> *@
<table class="table table-hover table-striped" style="table-layout: fixed; word-break: break-all;">
    <thead style="position: sticky;top: 3.5rem; z-index: 1; background-color: White">
        <tr>
            <th>Period</th>
            <th>Raw Material</th>
            <th>Semi-Products</th>
            <th>Finished goods/Trade</th>
            <th>FS Subtotal</th>
            <th>MTPT(Days)</th>
            <th>Received FS</th>
            <th>Consumption FS</th>
            <th>Gap</th>
        </tr>
    </thead>
    <tbody>
        @if (NavInvReportClassDtos.Count == 0)
        {
            <tr>
                <td colspan="9">请稍候，正在查询数据...</td>
            </tr>
        }
        else
        {
            @foreach (var dto in NavInvReportClassDtos)
            {
                <tr>
                    <td>@dto.YearMonth.ToString("yyyy-MM")</td>
                    <td>@dto.RawMtlValue</td>
                    <td>@dto.SemiProdValue</td>
                    <td>@dto.FgTradeValue</td>
                    <td>@dto.FsSubtotal</td>
                    <td>@dto.MTPT</td>
                    <td>@dto.RecvValue</td>
                    <td>@dto.ConsValue</td>
                    <td>@dto.Gap</td>
                </tr>
            }
        }
    </tbody>


</table>

@code {
    public ObservableRangeCollection<NavInvReportClassDto> NavInvReportClassDtos { get; } = new();

    protected override async Task OnParametersSetAsync()
    {
        var response = await NavInvReportClassService.GetAllAsync();
        if (response.Status)
        {
            NavInvReportClassDtos.ReplaceRange(response.Result.OrderByDescending(x => x.YearMonth));
            //异步方法需要主动告知前台状态已经发生改变
            StateHasChanged();
        }
    }

}
